
package cn.edu.scau.cmi.hombio.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.math.BigDecimal;

import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllMedicinePrices", query = "select myMedicinePrice from MedicinePrice myMedicinePrice"),
		@NamedQuery(name = "findMedicinePriceById", query = "select myMedicinePrice from MedicinePrice myMedicinePrice where myMedicinePrice.id = ?1"),
		@NamedQuery(name = "findMedicinePriceByPrice", query = "select myMedicinePrice from MedicinePrice myMedicinePrice where myMedicinePrice.price = ?1"),
		@NamedQuery(name = "findMedicinePriceByPrimaryKey", query = "select myMedicinePrice from MedicinePrice myMedicinePrice where myMedicinePrice.id = ?1") })

@Table(catalog = "pig", name = "medicine_price")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain", name = "MedicinePrice")

public class MedicinePrice implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "id", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@Id @GeneratedValue
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "Price", scale = 2, precision = 10)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	BigDecimal price;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "MedicineSupplier", referencedColumnName = "Id") })
	@XmlTransient
	MedicineSupplier medicineSupplier;
	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "MedicineStorage", referencedColumnName = "Id") })
	@XmlTransient
	MedicineStorage medicineStorage;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	/**
	 */
	public BigDecimal getPrice() {
		return this.price;
	}

	/**
	 */
	public void setMedicineSupplier(MedicineSupplier medicineSupplier) {
		this.medicineSupplier = medicineSupplier;
	}

	/**
	 */
	@JsonIgnore
	public MedicineSupplier getMedicineSupplier() {
		return medicineSupplier;
	}

	/**
	 */
	public void setMedicineStorage(MedicineStorage medicineStorage) {
		this.medicineStorage = medicineStorage;
	}

	/**
	 */
	@JsonIgnore
	public MedicineStorage getMedicineStorage() {
		return medicineStorage;
	}

	/**
	 */
	public MedicinePrice() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(MedicinePrice that) {
		setId(that.getId());
		setPrice(that.getPrice());
		setMedicineSupplier(that.getMedicineSupplier());
		setMedicineStorage(that.getMedicineStorage());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("price=[").append(price).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof MedicinePrice))
			return false;
		MedicinePrice equalCheck = (MedicinePrice) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
